#pragma once

#include "footage.h"

namespace icache {

class coordinator;

/// still_footage is footage from one frame only (stored in ordinary image file);
/// therefore it's not wise to create new thread (like in seq_reader)

class still_footage : public footage_simple_impl
{
public: //footage inerface
	virtual string filepath() const;
	virtual item_id_sptr frame_id(int frame);
	virtual cached_image_sptr get(int frame, nearby may_be_requested_later = no_nearby, bool wait = true);
	virtual cached_image_sptr try_get(int frame);
	virtual icache::cache * cache() const;
	virtual xml::stream & serialize(xml::stream & s, string const & reference_path);
	virtual string description() const;
	virtual int size() const;
	virtual int first_frame_num() const;
	virtual size_extent dim() const;
	virtual bool alpha_channel() const;
	virtual fraction fps() const;
public:
	still_footage(const string & filename = string(), icache::coordinator * c = 0);
	virtual ~still_footage();
	void open(const string & filename);
	void close();
	bool is_open() const;
	void coordinator(icache::coordinator * c);
	icache::coordinator * coordinator() const;
	string const & fullpath() const;
private:
	icache::coordinator * _coordinator;
	string _fullpath;
	size_extent _dim;
	bool _alpha;
};

//inlines

inline void still_footage::close()
	{ _fullpath.clear(); }

inline bool still_footage::is_open() const
	{ return !_fullpath.empty(); }

inline string const & still_footage::fullpath() const
	{ return _fullpath; }

inline void still_footage::coordinator(icache::coordinator * c)
	{ _coordinator = c; }

inline icache::coordinator * still_footage::coordinator() const
	{ return _coordinator; }

} //namespace icache
